﻿var football = require('./football_shua.js');
var routes = require('./routes.js');
var express = require('express');
var fs = require('fs');
var querystring = require('querystring');
var path = require('path');
//football.shua('102053', '7', '1', '0', '20');

var app = express();

//router
var index = express.Router();
	index.get('/', routes.index);
	index.get('/index', routes.index);
	index.get('/about', routes.about);
	index.post('/index/1', routes.yijian);
	index.post('/index/2', routes.duifu);
	index.post('/index/3', routes.qiuyuan);
	index.post('/index/4', routes.shengxing)

/*
app.get('/index.html', function(req, res){
    res.writeHead(200, {'Content-Type' : 'text/html'});
	var file = fs.createReadStream('index.html');
	file.pipe(res);
});

app.post('/index.html/1', function(req, res){
    req.on('data', function(data){
	    var obj = querystring.parse(data.toString());
		//res.send(obj.uid + obj.chaojibi);
		//res.send(obj.chaojibi);
		football.shua(obj.uid, '7', '2', '0', obj.chaojibi);
		football.shua(obj.uid, '1', '7', '0', obj.zijin);
		football.shua(obj.uid, '1', '2', '0', obj.jingyan);
		football.shua(obj.uid, '2', '11', '3000', obj.jingti);
		football.shua(obj.uid, '2', '11', '2114', obj.xunzhang);
	});
	res.send('ok');
});

app.post('/index.html/2', function(req, res){
    req.on('data', function(data){
	    var obj = querystring.parse(data.toString());
		football.xunhuan(obj.uid, '1', 100, 121);
	});
	res.send('ok');
});
*/

//配置
var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
    // configure stuff here
    app.set('view engine', 'ejs')
    app.use('/', index);
    //app.use('/form', form);
    app.use(express.static(path.join(__dirname, 'public')));
}

app.listen(80);